﻿

namespace MITC.Portal.Core.Entitys.Lienket
{

    #region  refer
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mitc.Portal.Core.Entitys.Lienket;
    using SPGenesis.Core;
    using Microsoft.SharePoint;
    using Mitc.Portal.Core.CoreHelper;
    #endregion 

    [SPGENListInstance(
         WebRelURL = "Lists/LienKet",
         Title = "Liên kết",
         OnQuickLaunch = false,
         TemplateType = (int)SPListTemplateType.GenericList
     )]
    public class LienketIntance : SPGENListInstance<LienketIntance>
    {

        protected override void InitializeDefinition(SPGENListInstanceProperties properties)
        {

            properties.Fields.ProvisioningMode = SPGENProvisioningMode.ExclusiveAdd;
            properties.Fields.Add<UrlLink>(true, false);
            properties.Fields.Add<LinkOrder>(true, false);
            properties.Fields.Add<Description>(true, false);
            properties.Fields.Add<TagetLink>(true, false);

        }

        [SPGENField(AllowMultipleValues = false, ID = "{554C1084-D957-4546-AD92-B1A7D90698C6}", DisplayName = "Đường dẫn liên kết", Type = SPFieldType.Note, Required = false)]
        public class UrlLink : SPGENField<UrlLink, SPFieldMultiLineText, string>
        {
        }

        [SPGENField(AllowMultipleValues = false, ID = "{7FEB362C-99F6-43FF-BB74-186B74C5F947}", DisplayName = "Vị trí hiển thị", Type = SPFieldType.Number, Required = false)]
        public class LinkOrder : SPGENField<LinkOrder, SPFieldNumber, int>
        {
        }

        [SPGENField(AllowMultipleValues = false, ID = "{0D2F2CFB-4CE4-469E-8AE4-D11087C5D8B0}", DisplayName = "Mô tả", Type = SPFieldType.Note, Required = false)]
        public class Description : SPGENField<Description, SPFieldMultiLineText, string>
        {
        }


        [SPGENField(AllowMultipleValues = false, ID = "{4EDE339C-8E47-4702-B911-DDD2764189BC}", DisplayName = "Kiểu hiển thị", Type = SPFieldType.Choice, Required = false)]
        public class TagetLink : SPGENField<TagetLink, SPFieldChoice, string>
        {
            protected override void InitializeDefinition(SPGENFieldProperties<SPFieldChoice> properties)
            {
                properties.ChoiceMappings.Clear();
                properties.ChoiceMappings.Add("1", StringHelper.GetDescriptionEnum(LinkTaget._blank));
                properties.ChoiceMappings.Add("2", StringHelper.GetDescriptionEnum(LinkTaget._seft));
                properties.ChoiceMappings.Add("3", StringHelper.GetDescriptionEnum(LinkTaget._parent));
                properties.ChoiceMappings.Add("4", StringHelper.GetDescriptionEnum(LinkTaget._top));
                properties.DefaultValue = StringHelper.GetDescriptionEnum(LinkTaget._blank);
            }

        }
    }
}
